import { apiRequest, get, put, del, post } from '../utils/api';
import { User, UserResponseDto, CreateUserDto, UpdateUserDto } from '../types/user';

// 获取当前用户信息（用户接口）
export const getCurrentUser = async (): Promise<User> => {
  return get<User>('/users/me');
};

// 更新用户信息
export const updateCurrentUser  = async (
  id: number,
  userData: UpdateUserDto
): Promise<UserResponseDto> => {
  return put<UserResponseDto>(`/users/me`, userData);
};


// 上传用户头像（用户接口）
export const uploadAvatar = async (formData: FormData): Promise<{ avatarUrl: string }> => {
  return post<{ avatarUrl: string }>('/users/me/avatar', formData);
};